const fs = require('fs')
const path = require('path')
let fliepath = path.join(__dirname,'./data/info.json')
function getStudents (){
   
    let  data = JSON.parse(fs.readFileSync(fliepath,'utf-8'))
  return data

}
function lucyStudents(){
    let arr =  getStudents ()
    let arrlucy = arr[Math.floor(Math.random()*arr.length)]
    arrlucy.count++
    console.log(arrlucy)
   return arrlucy
}
arrlucy = lucyStudents()
  // 写入 JSON 数据到文件中
  fs.writeFileSync(fliepath,JSON.stringify(arrlucy), { encoding: 'utf-8' })
// 导出模块
module.exports ={
    getStudents,
    lucyStudents
}


